package com.idanchuang.component.base.page.metadata;

import com.zoi7.component.core.util.page.SimplePage;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 自定义接收分页用
 * </p>
 *
 * @author jiang
 * @date 2019-11-05 10:03
 * @deprecated use {@link com.idanchuang.component.base.page.PageData} instead
 */
@Deprecated
public class DiyPage<T> extends SimplePage {

    /** 当前页 */
    private long current;
    /** 每页条数 */
    private long size;
    /** 总记录数 */
    private long total;
    /** 当前页记录 */
    private List<T> records;
    /** 总页数 */
    private long pages;

    public DiyPage() {
        this(1, DEF_COUNT, 0, new ArrayList<>());
    }

    public DiyPage(int pageNo, int pageSize, int totalCount) {
        this(pageNo, pageSize, totalCount, new ArrayList<>());
    }

    public DiyPage(int pageNo, int pageSize, int totalCount, List<T> records) {
        super(pageNo, pageSize, totalCount);
        this.current = super.pageNo;
        this.size = super.pageSize;
        this.total = totalCount;
        this.pages = super.getTotalPage();
        this.records = records;
    }

    public long getCurrent() {
        return this.current;
    }

    public DiyPage<T> setCurrent(long current) {
        this.current = current;
        return this;
    }

    public long getSize() {
        return this.size;
    }

    public DiyPage<T> setSize(long size) {
        this.size = size;
        return this;
    }

    public long getTotal() {
        return this.total;
    }

    public DiyPage<T> setTotal(long total) {
        this.total = total;
        return this;
    }

    public List<T> getRecords() {
        return this.records;
    }

    public DiyPage<T> setRecords(List<T> records) {
        this.records = records;
        return this;
    }

    public long getPages() {
        return this.pages;
    }

    public DiyPage<T> setPages(long pages) {
        this.pages = pages;
        return this;
    }

    @Override
    public String toString() {
        return "DiyPage{" +
                "current=" + current +
                ", size=" + size +
                ", total=" + total +
                ", records=" + records +
                ", pages=" + pages +
                '}';
    }
}
